<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"  > 

<h:head>
	<title>Registrazione</title>
    <h:outputStylesheet library="css" name="bootstrap.min.css"/>
</h:head> 
<body>
    <div class="container">
		<h:form >
			<p:messages />
			<p:panel header="Registrazione" >
				<p:panelGrid columns="3">
				
					<p:outputLabel for="name">Nome:</p:outputLabel>
					<p:inputText id="name" value="#{authentication.user.name}" required="true" validatorMessage="Nome troppo corto (minimo 3 caratteri)" requiredMessage="campo obbligatorio">
						<f:validateLength minimum="3" />
					</p:inputText>
					<p:message for="name" />
					
					<p:outputLabel for="surname">Cognome:</p:outputLabel>
					<p:inputText id="surname" value="#{authentication.user.surname}" required="true"  validatorMessage="Cognome troppo corto (minimo 3 caratteri)" requiredMessage="campo obbligatorio">
						<f:validateLength minimum="3" />
					</p:inputText>
					<p:message for="surname" />
					
					<p:outputLabel for="email">Email:</p:outputLabel>
					<p:inputText id="email" value="#{authentication.user.email}" required="true"  validatorMessage="inserire un valore corretto del formato email (xxxxx@xxxxx.xxx)" requiredMessage="campo obbligatorio">
						<f:validateRegex pattern="^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$" />
					</p:inputText>
					<p:message for="email" />
					
					<p:outputLabel for="password">Password:</p:outputLabel>
					<p:password id="password" value="#{authentication.user.password}" match="passwordConfirm" required="true" requiredMessage="campo obbligatorio"/>
					<p:message for="password" />
					
					
					<p:outputLabel for="passwordConfirm">Password:</p:outputLabel>
					<p:password id="passwordConfirm" value="#{authentication.user.password}" required="true" requiredMessage="campo obbligatorio" />
					<p:message for="passwordConfirm" />
					
					
					<h:commandButton value="Registrati" type="submit" action="#{authentication.registrationAction}" />
					
				</p:panelGrid>
			</p:panel>
		</h:form>
	</div>
</body> 
</html>
